//
//  NewCityDynamicImageCell.swift
//  XiaoJingMallSwift
//
//  Created by beisheng03 on 2017/9/12.
//  Copyright © 2017年 beisheng. All rights reserved.
//

import UIKit
import SDWebImage

class NewCityDynamicImageCell: BaseTableViewCell {
    
    @IBOutlet weak var imageViewW: NSLayoutConstraint!
    @IBOutlet weak var timeBgView: UIView!
    @IBOutlet weak var topBgView: UIView!
    @IBOutlet weak var imageViewH: NSLayoutConstraint!
    
    @IBOutlet weak var lekH: NSLayoutConstraint!
    @IBOutlet weak var lekW: NSLayoutConstraint!
    @IBOutlet weak var lektionView: ImageBrowser!

    
    var model : NewCityDynamicModel? {
        
        didSet{
            
            if model == nil {
                return
            }
            
            
            let url = URL(string: model!.message_cover)
            
            lektionView.thumPicURLs = [url!]

            
            let layout = lektionView.collectionViewLayout as! ImageBrowserFlowLayout
            
            QL1(layout)

            let (colleSize,itemSize) = layout.calculateSize(thumPicURLs: [url!], leftRightMargin: 16)
            
            imageViewH.constant = colleSize.height + 2
            
            imageViewW.constant = colleSize.width + 9
            
            lekW.constant = colleSize.width
            
            lekH.constant = colleSize.height
            
            // 8.3设置cell尺寸
            layout.itemSize = itemSize
    
            
            lektionView.reloadData()

//            
            
            
            
        }
        
    }
    
//    override func layoutSubviews() {
//        super.layoutSubviews()
//
//    }

    override func awakeFromNib() {
        super.awakeFromNib()
        topBgView.backgroundColor = UIColor.viewBgGrey()
        timeBgView.addCornerAndBorder(borderColor: nil, borderWidth: 0, masksToBounds: true, cornerRadius: 3)

        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
